package chapter1.view;
import chapter1.util.SingletonFactory;

import java.util.Scanner;
/**
 * @author 郑植航
 * @since 2025/6/16 19:05
 */


public class UserMode {
    public static final String MENU = """
            -------------
               员工模式
            -------------
            | 0 退出系统  |
            | 1 角色管理  |
            | 2 用户管理  |
            -------------
            请输入选项：""";
    //输出主界面菜单
    public static Scanner input;


    static {
        input = new Scanner(System.in);
    }

    private final RoleView roleView;
    private final UserView userView;


    private UserMode() {
        roleView = SingletonFactory.getInstance(RoleView.class);
        userView = SingletonFactory.getInstance(UserView.class);
    }


    public void show() {
        String menuChoice;
        do {
            System.out.print(MENU);
            menuChoice = input.nextLine();
            switch (menuChoice) {
                case "0" -> System.out.println("成功退出系统，欢迎再次使用！");
                case "1" -> roleView.show();
                case "2" -> userView.show();
                default -> System.out.print("输入非法，请输入正确的菜单编号！");
            }
        } while (!"0".equals(menuChoice));
    }
}
